package com.weibo.common.util;

import com.weibo.pojo.Message;
import com.weibo.pojo.Shell;
import com.weibo.pojo.WeiboComm;
import com.weibo.pojo.WeiiBoPojo;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;


public class FaceFormat {
	public static List<WeiiBoPojo> formt(List<WeiiBoPojo> list){
		if(list!=null){
			for(int i=0;i<list.size();i++){
				String body = list.get(i).getmBody();
				String replaceAll = body.replaceAll("\\[@", "<img src=\"gif/");
				String all = replaceAll.replaceAll("@\\]", ".gif\""+">");
				Date date = list.get(i).getmDate();
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				String pulishTime = sdf.format(date);
				list.get(i).setPublishTime(pulishTime);
				list.get(i).setmBody(all);
			}
		}
		return list;
	}
	
	public static List<WeiboComm> commFormt(List<WeiboComm> list){
		if(list!=null){
			for(int i=0;i<list.size();i++){
				String body = list.get(i).getCommentBody();
				String replaceAll = body.replaceAll("\\[@", "<img src=\"gif/");
				String all = replaceAll.replaceAll("@\\]", ".gif\""+">");
				list.get(i).setCommentBody(all);
			}
		}
		return list;
	}
	public static List<Message> messageFormt(List<Message> list){
		if(list!=null){
			for(int i=0;i<list.size();i++){
				String body = list.get(i).getMessage();
				String replaceAll = body.replaceAll("\\[@", "<img src=\"gif/");
				String all = replaceAll.replaceAll("@\\]", ".gif\""+">");
				list.get(i).setMessage(all);
			}
		}
		return list;
	}
	
	public static List<Shell> shellFormt(List<Shell> list){
		if(list!=null){
			for(int i=0;i<list.size();i++){
				String body = list.get(i).getShellBody();
				String replaceAll = body.replaceAll("\\[@", "<img src=\"gif/");
				String all = replaceAll.replaceAll("@\\]", ".gif\""+">");
				list.get(i).setShellBody(all);
			}
		}
		return list;
	}
	
	public static String conchFormt(String str){
		String toTrans = "";
		if(str!=null){
				String replaceAll = str.replaceAll("\\[@", "<img src=\"gif/");
				String all = replaceAll.replaceAll("@\\]", ".gif\""+">");
				toTrans = all;
		}
		return toTrans;
	}
	
	public static String keyFormt(String str,String key){
		String toTrans = "";
		if(str!=null){
				String replaceAll = str.replaceAll(key, "<span style='color:red'>"+key+"</span>");
				toTrans = replaceAll;
		}
		return toTrans;
	}
	public static void main(String[] args) {
		String string = FaceFormat.keyFormt("<img src='gif/F_51.gif'>傻孩砸", "傻孩砸");
		
		System.out.println(string);
	}
}
